package com.mmy.service.car.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.mmy.dao.car.TCarPlanRepository;
import com.mmy.dao.car.VCarPlanRepository;
import com.mmy.domain.car.TCarPlan;
import com.mmy.domain.car.VCarPlan;
import com.mmy.service.car.TCarPlanService;

@Service
public class TCarPlanServiceImpl implements TCarPlanService {
	@Autowired
	TCarPlanRepository tCarPlanRepository;
	@Autowired
	VCarPlanRepository vCarPlanRepository;

	/**
	 * 查找全部
	 * 
	 * @param
	 * @return
	 */
	public List<TCarPlan> findAll() {
		// TODO Auto-generated method stub
		return tCarPlanRepository.findAll();
	}

	/**
	 * 获取计划单最大编码
	 * 
	 * @return 返回值说明 计划单编码
	 * @author 创建人 dingxd
	 * @date 创建日期 2020.11.16
	 */
	public String getMaxPlanID() {
		// 返回计划单最大编码
		Object objCode = tCarPlanRepository.getMaxPlanID();
		String strPlanID = "";
		if (objCode != null) {
			strPlanID = objCode.toString();
		}
		return strPlanID;
	}

	/**
	 * 新建id
	 * 
	 * @param
	 * @return
	 */
	public void save(int planID) {
		// TODO Auto-generated method stub
		tCarPlanRepository.save(planID);
	}

	/**
	 * 新增
	 * 
	 * @param
	 * @return
	 */
	public void save(TCarPlan tCarPlan) {
		// TODO Auto-generated method stub
		tCarPlanRepository.save(tCarPlan);
	}

	/**
	 * 删除
	 * 
	 * @param
	 * @return
	 */
	public void delCarPlan(List<Integer> lstPlanID) {
		// TODO Auto-generated method stub
		tCarPlanRepository.delCarPlan(lstPlanID);
	}

	/**
	 * 通过id查找
	 * 
	 * @param
	 * @return
	 */
	public TCarPlan findByPlanID(int iPlanID) {
		// TODO Auto-generated method stub
		return tCarPlanRepository.findByPlanID(iPlanID);
	}

	/**
	 * 通过name查找
	 * 
	 * @param
	 * @return
	 */
	public List<TCarPlan> findByCarID(String strCarID) {
		// TODO Auto-generated method stub
		return tCarPlanRepository.findByCarID(strCarID);
	}

	/**
	 * 通过CarID查找
	 * 
	 * @param
	 * @return
	 */
	public List<VCarPlan> findByCarID(int iCarID) {
		// TODO Auto-generated method stub
		return vCarPlanRepository.findByCarID(iCarID);
	}

	/**
	 * 通过id查找
	 * 
	 * @param
	 * @return
	 */
	public VCarPlan findByID(int iPlanID) {
		// TODO Auto-generated method stub
		return vCarPlanRepository.findByID(iPlanID);
	}

}
